import React, { Component } from 'react';
import { WebView } from 'react-native-webview';

export default class HomeDetail extends Component {
  static navigationOptions = {
    title: '新闻详情',
  };
  state = {
    htmlContent: ''
  }
  componentDidMount = async () => {
    const { url } = this.props.navigation.state.params;
    const res = await fetch(url);
    const resText = await res.text();
    this.setState({ htmlContent: resText })
  }
  
  render() {
    const { htmlContent } = this.state;
    return (
        <WebView
          startInLoadingState
          originWhitelist={['*']}
          source={{ html: htmlContent }}
        />
    )
  }
}

